{include file="header"}
<div class="layui-tab layui-tab-brief adminmyucms" lay-filter="docDemoTabBrief" style="padding: 20px;">
<form class="layui-form" action="">
  <div class="layui-form-item" >
      <span style="float: left;line-height: 38px;margin: 0 20px;">名称</span>
	  <input type="text" name="title" value=""  placeholder="例如‘版权信息’" autocomplete="off" lay-verify="required" class="layui-input" style="width: 150px;float: left;">
      <span style="float: left;line-height: 38px;margin: 0 20px;">标识</span>
	  <input type="text" name="set" value=""  placeholder="请输入英文字符组成" autocomplete="off" lay-verify="required" class="layui-input" style="width: 150px;float: left;">
      <span style="float: left;line-height: 38px;margin: 0 20px;">排序</span>
	  <input type="number" name="px" value="1"  placeholder="请输入英文字符组成" autocomplete="off" lay-verify="required" class="layui-input" style="width: 50px;float: left;">
      <span style="float: left;line-height: 38px;margin: 0 20px;">选择</span>
     <div style="width: 150px;float: left;">
      <select name="choice" lay-verify="required">
      	<option value=""></option>
        <option value="1">单行输入框</option>
        <option value="2">普通文本域</option>
        <option value="3">文件上传</option>
        <option value="4">单选框</option>
      </select>
    </div>
    <span style="float: left;line-height: 38px;margin: 0 20px;">位置</span>
     <div style="width: 150px;float: left;">
      <select name="fl" lay-verify="required">
        <option value="5">自定义</option>
      </select>
    </div>
    <button style="float: left;line-height: 38px;margin: 0 20px;" class="layui-btn layui-btn-normal" lay-submit lay-filter="set-add">添加变量</button>
    </div>
</form>
  <ul class="layui-tab-title">
    <li class="layui-this">基本配置</li>
    <li>全局主题</li>
    <li>积分管理</li>
    <li>邮件配置</li>
    <li>自定义页面模板</li>
    <li>用户自定义</li>
  </ul>
  <div class="layui-tab-content">
<!--基本设置-->
<div class="layui-tab-item layui-show">
{volist name=":fun_s('set',array('open'=>1,'fl'=>1),'px desc',100,1)" id="or"}
<form class="layui-form" action="">
<input type="hidden" name="id" value="{$or.id}">	
<table class="layui-table">
  <colgroup>
    <col width="100">
    <col width="500">
    <col width="100">
    <col width="100">
 
    <col>
  </colgroup>
  <tbody>
    <tr>
      <td>{$or.title}</td>
      <td>
      {if condition="$or['choice'] eq '1'"}
      <input type="text" name="name" value="{$or.name|htmlspecialchars}" placeholder="请输入内容" autocomplete="off" class="layui-input">
      {elseif condition="$or['choice'] eq '2'"}
      <textarea name="name" placeholder="请输入内容" class="layui-textarea">{$or.name|htmlspecialchars}</textarea>
       {elseif condition="$or['choice'] eq '3'"}
       <div class="layui-col-md8">
     <input type="text" name="name" value="{$or.name|htmlspecialchars}"  id="ups{$or.id}" placeholder="请输入内容" autocomplete="off" class="layui-input">
     </div> 
     <div class="layui-col-md4">
     	<button type="button" name="name" class="layui-btn layui-btn-danger" id="up{$or.id}"><i class="layui-icon"></i>上传</button>
     </div> 
     <script>
     layui.use('upload', function(){
     	var $ = layui.jquery
     	,upload = layui.upload;
     	jq = layui.jquery;
		upload.render({
			elem: '#up{$or.id}',
			url: "{:url("up/up")}",
			accept: 'file',
			//exts: 'zip|rar|7z',
			done: function(res) {
				if (res.code == '200') {
					jq('input[id=ups{$or.id}').val(res.path);
					return layer.msg(res.msg);
				} else {
					return layer.msg(res.msg);
				}
			}
		});
       });
      </script>
      {elseif condition="$or['choice'] eq '4'"}
      <input type="radio" name="name" value="1" title="开启" {if condition="$or['name'] eq '1'"}checked{/if}>
      <input type="radio" name="name" value="0" title="关闭" {if condition="$or['name'] eq '0'"}checked{/if}>
      {/if}
      </td>
      <td>
      <input type="number" name="px" value="{$or.px}" placeholder="请输入英文字符组成" autocomplete="off" lay-verify="required" class="layui-input" style="float: left;">
      </td>
      <td><button class="layui-btn layui-btn-normal" style="float: left;" lay-submit lay-filter="set"><i class="layui-icon">&#xe9aa;</i> 更新</button></td>
 
    </tr>
  </tbody>
</table>
</form>
{/volist}  
<form class="layui-form" action="">
<table class="layui-table">
<colgroup>
    <col width="100">
    <col width="300">
    <col width="200">
    <col width="100">
    <col width="300">
    <col width="150">
    <col>
  </colgroup>
  <tbody>
    <tr>
      <td>调试模式</td>
      <td>
      <input type="radio" name="BUG" value="1" title="开启" {if condition="config('web.BUG') eq 1"}checked{/if}>
      <input type="radio" name="BUG" value="0" title="关闭" {if condition="config('web.BUG') eq 0"}checked{/if}>
      </td>
 
      <td id="biao1">正式上线请关闭调试</td>
      <td>伪静态</td>
      <td>
      <input type="radio" name="WEIJINGTAI" value="1" title="开启" {if condition="config('web.WEIJINGTAI') eq 1"}checked{/if}>
      <input type="radio" name="WEIJINGTAI" value="0" title="关闭" {if condition="config('web.WEIJINGTAI') eq 0"}checked{/if}>
      </td>
      <td><button class="layui-btn layui-btn-normal" style="float: left;" lay-submit="" lay-filter="set_web"><i class="layui-icon"></i> 更新</button></td>
    </tr>
  </tbody>
</table>
</form>
</div>
<!--基本设置-->
<!--全局主题-->
<div class="layui-tab-item">
{volist name=":fun_s('set',array('open'=>1,'fl'=>2),'px desc',100,1)" id="or"}
<form class="layui-form" action="">
<input type="hidden" name="id" value="{$or.id}">	
<table class="layui-table">
  <colgroup>
    <col width="100">
    <col width="550">
    <col width="100">
    <col>
  </colgroup>
  <tbody>
    <tr>
      <td>{$or.title}</td>
      <td>
      <textarea name="name" placeholder="请输入内容" class="layui-textarea" style="height: 300px;">{$or.name|htmlspecialchars}</textarea>
      </td>
      <td><button class="layui-btn layui-btn-normal" style="float: left;" lay-submit lay-filter="set"><i class="layui-icon">&#xe9aa;</i> 更新</button></td>
  
    </tr>
  </tbody>
</table>
</form>
{/volist}  
</div>
<!--全局主题-->

<!--积分管理-->
<div class="layui-tab-item">
{volist name=":fun_s('set',array('open'=>1,'fl'=>3),'px desc',100,1)" id="or"}
<form class="layui-form" action="">
<input type="hidden" name="id" value="{$or.id}">	
<table class="layui-table">
  <colgroup>
    <col width="100">
    <col width="500">
    <col width="100">
    <col width="100">
 
    <col>
  </colgroup>
  <tbody>
    <tr>
      <td>{$or.title}</td>
      <td>
      {if condition="$or['choice'] eq '1'"}
      <input type="text" name="name" value="{$or.name|htmlspecialchars}" placeholder="请输入内容" autocomplete="off" class="layui-input">
      {elseif condition="$or['choice'] eq '2'"}
      <textarea name="name" placeholder="请输入内容" class="layui-textarea">{$or.name|htmlspecialchars}</textarea>
       {elseif condition="$or['choice'] eq '3'"}
       <div class="layui-col-md8">
     <input type="text" name="name" value="{$or.name|htmlspecialchars}"  placeholder="请输入内容" autocomplete="off" class="layui-input">
     </div> 
     <div class="layui-col-md4">
     	<button type="button" name="name" class="layui-btn layui-btn-danger" id="up{$or.id}"><i class="layui-icon"></i>上传图片</button>
     </div> 
     <script>
     layui.use('upload', function(){
     	var $ = layui.jquery
     	,upload = layui.upload;
     	jq = layui.jquery;
		upload.render({
			elem: '#up{$or.id}',
			url: "{:url("up/up")}",
			accept: 'file',
			done: function(res) {
				if (res.code == '200') {
					jq('input[id=ups{$or.id}').val(res.headpath);
					return layer.msg(res.msg);
				} else {
					return layer.msg(res.msg);
				}
			}
		});
       });
      </script>
      {elseif condition="$or['choice'] eq '4'"}
      <input type="radio" name="name" value="1" title="开启"  {if condition="$or['name'] eq '1'"}checked{/if}>
      <input type="radio" name="name" value="0" title="关闭"  {if condition="$or['name'] eq '0'"}checked{/if}>
      {/if}
      </td>
      <td>
      <input type="number" name="px" value="{$or.px}" placeholder="请输入英文字符组成" autocomplete="off" lay-verify="required" class="layui-input" style="float: left;">
      </td>
      <td><button class="layui-btn layui-btn-normal" style="float: left;" lay-submit lay-filter="set"><i class="layui-icon">&#xe9aa;</i> 更新</button></td>
 
 
    </tr>
  </tbody>
</table>
</form>
{/volist}  
</div>
<!--积分管理-->

<!--邮件配置-->
<div class="layui-tab-item">
{volist name=":fun_s('set',array('open'=>1,'fl'=>4),'px desc',100,1)" id="or"}
<form class="layui-form" action="">
<input type="hidden" name="id" value="{$or.id}">	
<table class="layui-table">
  <colgroup>
    <col width="100">
    <col width="500">
    <col width="100">
    <col width="100">
 
    <col>
  </colgroup>
  <tbody>
    <tr>
      <td>{$or.title}</td>
      <td>
      {if condition="$or['choice'] eq '1'"}
      <input type="text" name="name" value="{$or.name|htmlspecialchars}" placeholder="请输入内容" autocomplete="off" class="layui-input">
      {elseif condition="$or['choice'] eq '2'"}
      <textarea name="name" placeholder="请输入内容" class="layui-textarea">{$or.name|htmlspecialchars}</textarea>
       {elseif condition="$or['choice'] eq '3'"}
       <div class="layui-col-md8">
     <input type="text" name="name" value="{$or.name|htmlspecialchars}"  placeholder="请输入内容" autocomplete="off" class="layui-input">
     </div> 
     <div class="layui-col-md4">
     	<button type="button" name="name" class="layui-btn layui-btn-danger" id="up{$or.id}"><i class="layui-icon"></i>上传图片</button>
     </div> 
     <script>
     layui.use('upload', function(){
     	var $ = layui.jquery
     	,upload = layui.upload;
     	jq = layui.jquery;
		upload.render({
			elem: '#up{$or.id}',
			url: "{:url("up/up")}",
			accept: 'file',
			done: function(res) {
				if (res.code == '200') {
					jq('input[id=ups{$or.id}').val(res.headpath);
					return layer.msg(res.msg);
				} else {
					return layer.msg(res.msg);
				}
			}
		});
       });
      </script>
      {elseif condition="$or['choice'] eq '4'"}
      <input type="radio" name="name" value="1" title="开启"  {if condition="$or['name'] eq '1'"}checked{/if}>
      <input type="radio" name="name" value="0" title="关闭"  {if condition="$or['name'] eq '0'"}checked{/if}>
      {/if}
      </td>
      <td>
      <input type="number" name="px" value="{$or.px}" placeholder="请输入英文字符组成" autocomplete="off" lay-verify="required" class="layui-input" style="float: left;">
      </td>
      <td><button class="layui-btn layui-btn-normal" style="float: left;" lay-submit lay-filter="set"><i class="layui-icon">&#xe9aa;</i> 更新</button></td>
 
    </tr>
  </tbody>
</table>
</form>
{/volist}  
<form class="layui-form" action="">
<input type="hidden" name="id" value="{$or.id}">	
<table class="layui-table">
  <colgroup>
    <col width="100">
    <col width="300">
    <col width="300">
    <col width="300">
    <col width="100">
    <col width="300">
    <col>
  </colgroup>
  <tbody>
    <tr>
      <td>测试发送</td>
      <td>
      <input type="text" name="mail" value="" placeholder="请输入邮箱" autocomplete="off" lay-verify="required|email" class="layui-input">
      </td>
      <td>
      <input type="text" name="title" value="这是标题" placeholder="请输入内容" autocomplete="off" class="layui-input">
      </td>
      <td>
      <input type="text" name="name" value="测试内容" placeholder="请输入内容" autocomplete="off" class="layui-input">
      </td>
      <td><button class="layui-btn layui-btn-warm" style="float: left;" lay-submit lay-filter="setmail"><i class="layui-icon">&#xe9aa;</i> 发送</button></td>
      <td>点击无反应说明配置错误发送失败</td>
    </tr>
  </tbody>
</table>
</form>

</div>
<!--邮件配置-->
<!--自定义页面模板-->
<div class="layui-tab-item">
{volist name=":fun_s('set',array('open'=>1,'fl'=>6),'px desc',100,1)" id="or"}
<form class="layui-form" action="">
<input type="hidden" name="id" value="{$or.id}">	
<table class="layui-table">
  <colgroup>
    <col width="100">
    <col width="500">
    <col width="100">
    <col width="100">
    <!--
    <col width="250">
    -->
    <col>
  </colgroup>
  <tbody>
    <tr>
      <td>{$or.title}</td>
      <td>
      {if condition="$or['choice'] eq '1'"}
      <input type="text" name="name" value="{$or.name|htmlspecialchars}" placeholder="留空默认" autocomplete="off" class="layui-input">
      {elseif condition="$or['choice'] eq '2'"}
      <textarea name="name" placeholder="留空默认" class="layui-textarea">{$or.name|htmlspecialchars}</textarea>
       {elseif condition="$or['choice'] eq '3'"}
       <div class="layui-col-md8">
     <input type="text" name="name" value="{$or.name|htmlspecialchars}"  placeholder="留空默认" autocomplete="off" class="layui-input">
     </div> 
     <div class="layui-col-md4">
     	<button type="button" name="name" class="layui-btn layui-btn-danger" id="up{$or.id}"><i class="layui-icon"></i>上传图片</button>
     </div> 
     <script>
     layui.use('upload', function(){
     	var $ = layui.jquery
     	,upload = layui.upload;
     	jq = layui.jquery;
		upload.render({
			elem: '#up{$or.id}',
			url: "{:url("up/up")}",
			accept: 'file',
			done: function(res) {
				if (res.code == '200') {
					jq('input[id=ups{$or.id}').val(res.headpath);
					return layer.msg(res.msg);
				} else {
					return layer.msg(res.msg);
				}
			}
		});
       });
      </script>
      {elseif condition="$or['choice'] eq '4'"}
      <input type="radio" name="name" value="1" title="开启"  {if condition="$or['name'] eq '1'"}checked{/if}>
      <input type="radio" name="name" value="0" title="关闭"  {if condition="$or['name'] eq '0'"}checked{/if}>
      {/if}
      </td>
      <td>
      <input type="number" name="px" value="{$or.px}" placeholder="请输入英文字符组成" autocomplete="off" lay-verify="required" class="layui-input" style="float: left;">
      </td>
      <td><button class="layui-btn layui-btn-normal" style="float: left;" lay-submit lay-filter="set"><i class="layui-icon">&#xe9aa;</i> 更新</button></td>
      <!--
      <td id="biao1">标签: &#123;:cms('{$or.set}')&#125;</td>
      -->
    </tr>
  </tbody>
</table>
</form>
{/volist}  
</div>
<!--自定义页面模板-->
<!--自定义-->
<div class="layui-tab-item">
{volist name=":fun_s('set',array('open'=>1,'fl'=>5),'px desc',100,1)" id="or"}
<form class="layui-form" action="">
<input type="hidden" name="id" value="{$or.id}">	
<table class="layui-table">
  <colgroup>
    <col width="100">
    <col width="500">
    <col width="100">
    <col width="100">
    <col width="50">
    <col width="250">
    <col>
  </colgroup>
  <tbody>
    <tr>
      <td>{$or.title}</td>
      <td>
      {if condition="$or['choice'] eq '1'"}
      <input type="text" name="name" value="{$or.name|htmlspecialchars}" placeholder="请输入内容" autocomplete="off" class="layui-input">
      {elseif condition="$or['choice'] eq '2'"}
      <textarea name="name" placeholder="请输入内容" class="layui-textarea">{$or.name|htmlspecialchars}</textarea>
       {elseif condition="$or['choice'] eq '3'"}
       <div class="layui-col-md8">
     <input type="text" name="name" value="{$or.name|htmlspecialchars}"  placeholder="请输入内容" autocomplete="off" class="layui-input">
     </div> 
     <div class="layui-col-md4">
     	<button type="button" name="name" class="layui-btn layui-btn-danger" id="up{$or.id}"><i class="layui-icon"></i>上传图片</button>
     </div> 
     <script>
     layui.use('upload', function(){
     	var $ = layui.jquery
     	,upload = layui.upload;
     	jq = layui.jquery;
		upload.render({
			elem: '#up{$or.id}',
			url: "{:url("up/up")}",
			accept: 'file',
			done: function(res) {
				if (res.code == '200') {
					jq('input[id=ups{$or.id}').val(res.headpath);
					return layer.msg(res.msg);
				} else {
					return layer.msg(res.msg);
				}
			}
		});
       });
      </script>
      {elseif condition="$or['choice'] eq '4'"}
      <input type="radio" name="name" value="1" title="开启"  {if condition="$or['name'] eq '1'"}checked{/if}>
      <input type="radio" name="name" value="0" title="关闭"  {if condition="$or['name'] eq '0'"}checked{/if}>
      {/if}
      </td>
      <td>
      <input type="number" name="px" value="{$or.px}" placeholder="请输入英文字符组成" autocomplete="off" lay-verify="required" class="layui-input" style="float: left;">
      </td>
      <td><button class="layui-btn layui-btn-normal" style="float: left;" lay-submit lay-filter="set"><i class="layui-icon">&#xe9aa;</i> 更新</button></td>
       <td>
       	<button type="button" class="layui-btn layui-btn-sm layui-btn-danger" lay-submit lay-filter="set-delete">
          <i class="layui-icon">&#xe640;</i> 删除
        </button>
       	</td>
      <td id="biao1">标签: &#123;:cms('{$or.set}')&#125;</td>
    </tr>
  </tbody>
</table>
</form>
{/volist}  
</div>
<!--自定义-->
 </div>
<script>
layui.use('form',function(){
  var form = layui.form
  ,jq = layui.jquery;
  //web.php
  form.on('submit(set_web)', function(data){
    loading = layer.load(2, {
      shade: [0.2,'#000']
    });
    var param = data.field;
    jq.post('{:url("set/web")}',param,function(data){
      if(data.code == 200){
        layer.close(loading);
        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
          //location.href = '{:url("index/index")}';
        });
      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
      }
    });
    return false;
  });
  //更新
  form.on('submit(set)', function(data){
    loading = layer.load(2, {
      shade: [0.2,'#000']
    });
    var param = data.field;
    jq.post('{:url("set/set")}',param,function(data){
      if(data.code == 1){
        layer.close(loading);
        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
          //location.href = '{:url("index/index")}';
        });
      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
      }
    });
    return false;
  });
  //删除
  form.on('submit(set-delete)', function(data){
    var param = data.field;
        layer.confirm('确定删除? 删除前请慎重', function(index){
      loading = layer.load(2, {
        shade: [0.2,'#000']
      });
    jq.post('{:url("set/setdelete")}',param,function(data){
      if(data.code == 1){
        layer.close(loading);
        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
          location.reload();
        });
      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
      }
    });
   }); 
    return false;
  });
  //添加变量
  form.on('submit(set-add)', function(data){
    loading = layer.load(0, {
      shade: [0.2,'#000']
    });
    var param = data.field;
    jq.post('{:url("set/setadd")}',param,function(data){
      if(data.code == 1){
        layer.close(loading);
        layer.msg(data.msg, {icon: 1, time: 1000}, function(){
          location.reload();
        });
      }else{
        layer.close(loading);
        layer.msg(data.msg, {icon: 2, anim: 6, time: 1000});
      }
    });
    return false;
  });
  
  //邮件测试
  form.on('submit(setmail)', function(data){
    var param = data.field;
    jq.post('{:url("set/email")}',param,function(data){
      if(data.code == 200){
        layer.msg('发送成功');
      }
    });
    return false;
  });
  
})
</script>
</div>  
{include file="footer"}